﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true" CodeBehind="OrganizationManageRoleList.aspx.cs" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.Organization.OrganizationManageRoleList" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<title>组织[管理角色]列表</title>
<web:Script ID="Script4" src="~/Modules/SecurityConsole/Common/FunctionControl/ListSelect/ListSelectControl.js" runat="server" />
</asp:Content>
<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">  
<script type="text/javascript">
    var Global = {};
    Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
</script>
    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				    组织[管理角色]列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton ID="addFunctionID" runat="server"
                OnClientClick="return addRolesForOrganization();" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />添加角色
                </span>
            </asp:LinkButton>
            <asp:LinkButton ID="LinkButton2" runat="server"
                OnClientClick="return removeRoles();" OnClick="RemoveRolesFromUser">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/ico_del.gif" style="border: 0px" />移除角色
                </span>
            </asp:LinkButton>
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="RoleId" DataSourceID="ManageRoleDataSource" 
                PageSize="10">
                <Columns>            
                    <asp:CheckBoxField DataField="RoleId" ItemStyle-HorizontalAlign="Center" />    
                    <asp:BoundField DataField="RoleName" HeaderText="角色名称" SortExpression="RoleName" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="RoleDescription" HeaderText="角色说明" SortExpression="RoleDescription" ItemStyle-HorizontalAlign="Left"/>
                    <asp:TemplateField HeaderText="操作">
                
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="移除" ImageUrl="~/Images/ico_del.gif" _KeyId='<%#Eval("RoleId")%>'
                                            CausesValidation="False" OnClientClick="return window.confirm('您确认要移除该角色吗?')" OnClick="RemoveRoleFromUser">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                 <CheckBoxSettings Enabled="True" Position="0"/>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="ManageRoleDataSource" runat="server" SelectCommand="organization.organization_manage_role_list" SelectCommandAutoPageWrap="true" DefaultSortExpression="RoleId ASC"></web:SmartSqlDataSource>
        </div>
	</div>
    <div class="itemdetail">
        <!-- 页脚区域 -->
	<div class="footer">
        <asp:Button ID="CloseButton2" runat="server" Text="关闭" OnClientClick="return closeDialog();" />        
	</div>
        </div>
    
      <script type="text/javascript">
          var orgId = '<%=Request.Params["OrgId"] %>';

          function addRolesForOrganization() {
              var listSelect = new ListSelect();
              listSelect.setSaveService("OrganizationAddManageRole");
              listSelect.setSearch("角色名称");
              listSelect.setSelectList("sql", "organization.role.searchManageRoleByName");
              listSelect.setParams("{'ORG_ID':'" + orgId + "'}");
              listSelect.setTitle('添加角色');
              var result = listSelect.show(Global.contextPath);
              if (result) {
                  return true;
              }
              return false;
          }

          function removeRoles() {
              var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
              var sValues = oSmartGridView1.control.getCheckedValues(true);

              if (sValues && sValues.length > 0) {
                  if (window.confirm("您确认要删除所选的角色吗？")) {
                      return true;
                  }
              }

              return false;
          }    
    </script>
</asp:Content>